typedef enum {
	PORT_EMPTY = 0,
	PORT_FILE = 1,
	PORT_PIPE = 2
} port_tag;

typedef struct port {
	port_tag tag;
	union {
		FILE* port;
		FILE* pipe[2];
	} body;
} port;

extern port port_table[100];
extern port empty_port;

void init_port_table();
scm next_port(void);
scm mk_port(FILE *f);
scm mk_pipe(FILE *f, FILE *g);
FILE* port_get_file(scm p);
FILE* port_get_pipe_end(scm p);
int port_empty(scm p);
void port_close(scm p);
